package com.es.designmode.singleinstance;

/**
 * 单例类
 * DLC 锁模式
 *
 * @author Will
 */
public class SingleInstance {

    private static volatile SingleInstance instance = null;

    private SingleInstance() {
    }

    /**
     * 单例实现
     *
     * @return instance
     */
    public static SingleInstance getInstance() {
        if (instance == null) {
            synchronized (SingleInstance.class) {
                if (instance == null) {
                    instance = new SingleInstance();
                }
            }
        }
        return instance;
    }

    /**
     * 具体方法实现
     */
    public void execute() {

        System.err.println("测试单例！");
    }
}
